package com.speechb.common.text;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author : llj
 * @version :2.1.0
 * @date : 2020/3/26 22:52
 */
public class UnicodeUtil {
    public static String unicodeToGbk(String unicodeText) {
        Pattern p = Pattern.compile("[u][\\w]{4}");
        Matcher m = p.matcher(unicodeText);
        StringBuilder sbu = new StringBuilder();
        while (m.find()) {
            String str = m.group();
            sbu.append((char) (Integer.parseInt(str.substring(1), 16)));
        }
        return sbu.toString();
    }
}
